import {route,GET,POST,before} from 'awilix-koa';

@route('/test')
export default class testAPI {
  constructor({testService}){
    console.log('testAPI testAPI')
    this.testService = testService;
  }

  @GET()
  async getData(ctx) {
    const result = await this.testService.getData();
    ctx.body = await ctx.render('index', result);
  }

  @route("/:id")
  @GET()
  async getByID(ctx) {
    const result = this.testService.getByID(ctx.params.id);
    ctx.body = await ctx.render('index', result);
  }
}